package com.gin.supermarket_inventory_system.commodity.dto.param;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gin.database.dto.param.BasePageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Comment;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
 * 商品分页查询参数
 * @since : 2023/10/10 09:31
 * @author : ginstone
 * @version : v1.0.0
 **/
@Getter
@Setter
@Schema(description = "商品分页查询参数")
public class CommodityPageParam extends BasePageParam {
    @Comment("商品类型ID")
    List<Long> typeId;

    @Column
    @Comment("商品生产商ID")
    List<Long> producerId;

    @Override
    public void handleQueryWrapper(QueryWrapper<?> queryWrapper) {
        if (!ObjectUtils.isEmpty(typeId)) {
            queryWrapper.in("type_id",typeId);
        }
        if (!ObjectUtils.isEmpty(producerId)) {
            queryWrapper.in("producer_id",producerId);
        }

    }
}
